<!-- 见证任务主页 -->
<template>
  <div>
    <TabMenu :tabList="tabList" :back-btn=true />
    <router-view />
  </div>
</template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
import TabMenu from "../../../../components/layout/components/tabMenu.vue";
import { page, taskList } from "../../../../api/weeon/myWitness";
export default {
  // 引入组件
  components: {
    TabMenu,
  },
  props: {},
  data() {
    // 这里存放数据
    return {
      bdid:"",
      activeName: "Witnessing",
      tabList:[],

      /*tabList: [
        {
          name: "zbStage",
          path: "/witnessStage/zbStage",
          title: "招标阶段",
          params: {bdid: this.$route.query.bdid}
        },
        {
          name: "tbStage",
          path: "/witnessStage/tbStage",
          title: "投标阶段",
          params: {bdid: this.$route.query.bdid}
        },
        {
          name: "kbStage",
          path: "/witnessStage/kbStage",
          title: "开标阶段",
          params: {bdid: this.$route.query.bdid}
        },
        {
          name: "pbStage",
          path: "/witnessStage/pbStage",
          title: "评标阶段",
          params: {bdid: this.$route.query.bdid}
        },
        {
          name: "dbStage",
          path: "/witnessStage/dbStage",
          title: "定标阶段",
          params: {bdid: this.$route.query.bdid}
        }
      ],*/
    };
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    this.bdid = this.$route.query.bdid;
    this.initTab(this.bdid);
  },
  // 生命周期 - 销毁之前
  beforeDestroy() {},
  // 生命周期 - 销毁完成
  destroyed() {},
  // 如果页面有keep-alive缓存功能，这个函数会触发
  activated() {},
  // 方法集合
  methods: {
    async initTab() {
      try {
        this.tableLoading = true;
        this.tableData = [];
        let params = {
          bdid :this.bdid
        };
        const res = await taskList(params);
        if (res.stat === 1) {
          res.data.forEach(item => {
            let obj = {};
            obj.title=item.taskname;
            obj.params={bdid: this.bdid, taskid:item.id};
            if (item.taskcode === "ZB") {
              obj.name="zbStage";
              obj.path="/witnessStage/zbStage";
            }else if (item.taskcode === "TB") {
              obj.name="tbStage";
              obj.path="/witnessStage/tbStage";
            }else if (item.taskcode === "KB") {
              obj.name="kbStage";
              obj.path="/witnessStage/kbStage";
            }else if (item.taskcode === "PB") {
              obj.name="pbStage";
              obj.path="/witnessStage/pbStage";
            }else if (item.taskcode === "DB") {
              obj.name="dbStage";
              obj.path="/witnessStage/dbStage";
            }else if (item.taskcode === "LY") {
              obj.name="lyStage";
              obj.path="/witnessStage/lyStage";
            }
            this.tabList.push(obj);
          })

        } else {
          this.$message({
            type: "error",
            message: res.msg || "获取数据失败，请稍后再试",
            single: true
          });
        }
      } catch (error) {
        console.log(error);
      }
    },
  },
};
</script>
<style lang='scss' scoped>
</style>
